/**
 * Urban Parks
 *
 * Team M&M's:
 * Michael Satran Jr
 * Michael Pogson
 * Stephen Hunter
 *
 * Date: Feb 16, 2012
 */
package view;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import model.Volunteer;

/**
 * Panel which shows the information of a Volunteer.
 * 
 * @author Michael Satran Jr
 */
public class VolunteerInfoPanel extends JPanel {
	
	/**
	 * The volunteer to show information for.
	 */
	private Volunteer my_volunteer;
	
	/**
	 * Constructs a new VolunteerInformationPanel
	 * @param the_volunteer The volunteer to show.
	 * @throws IllegalArgumentException Throws this if the volunteer is null.
	 */
	public VolunteerInfoPanel(Volunteer the_volunteer) throws IllegalArgumentException {
		super();
		if (the_volunteer != null) {
			my_volunteer = the_volunteer;
		} else {
			throw new IllegalArgumentException("A volunteer has not been selected");
		}
	}
	
	/**
	 * Sets up this panel by adding components etc.
	 */
	public void setup() {
			
			this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
			JPanel[] lines = new JPanel[4];
			
			for (int i = 0; i < lines.length; i++) {
				lines[i] = new JPanel();
				lines[i].setLayout(new BorderLayout());
				JLabel new_label = new JLabel();
				JLabel data_label = new JLabel();
				switch(i) {
				case 0:
					new_label.setText("Volunteer Name: ");
					data_label.setText(my_volunteer.getFirstName() + " " + my_volunteer.getLastName());
					break;
				case 1:
					new_label.setText("Blackballed: ");
					data_label.setText(Boolean.toString(my_volunteer.isBlackBalled()));
					break;
				case 2:
					new_label.setText("Email: ");
					data_label.setText(my_volunteer.getEmail());
					break;
				case 3:
					new_label.setText("Phone Number: ");
					data_label.setText(my_volunteer.getPhoneNumber());
					break;
				}
				lines[i].add(new_label, BorderLayout.WEST);
				lines[i].add(data_label, BorderLayout.CENTER);
				this.add(lines[i]);
			}
			this.setPreferredSize(new Dimension(500, 100));
	}

}
